package com.ruoyi.swimming.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.swimming.domian.MallCustomerAddress;
import com.ruoyi.swimming.domian.MallGoods;
import com.ruoyi.swimming.mapper.MallCustomerAddressMapper;
import com.ruoyi.swimming.mapper.MallGoodsMapper;
import com.ruoyi.swimming.service.IMallGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 商城商品Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-17
 */
@Service
public class MallGoodsServiceImpl extends ServiceImpl<MallGoodsMapper, MallGoods> implements IMallGoodsService
{
    @Autowired
    private MallGoodsMapper mallGoodsMapper;

    /**
     * 查询商城商品
     * 
     * @param id 商城商品ID
     * @return 商城商品
     */
    @Override
    public MallGoods selectMallGoodsById(Long id)
    {
        return mallGoodsMapper.selectMallGoodsById(id);
    }

    /**
     * 查询商城商品列表
     * 
     * @param mallGoods 商城商品
     * @return 商城商品
     */
    @Override
    public List<MallGoods> selectMallGoodsList(MallGoods mallGoods)
    {
        return mallGoodsMapper.selectMallGoodsList(mallGoods);
    }

    /**
     * 新增商城商品
     * 
     * @param mallGoods 商城商品
     * @return 结果
     */
    @Override
    public int insertMallGoods(MallGoods mallGoods)
    {
        mallGoods.setCreateTime(DateUtils.getNowDate());
        return mallGoodsMapper.insert(mallGoods);
    }

    /**
     * 修改商城商品
     * 
     * @param mallGoods 商城商品
     * @return 结果
     */
    @Override
    public int updateMallGoods(MallGoods mallGoods)
    {
        mallGoods.setUpdateTime(DateUtils.getNowDate());
        return mallGoodsMapper.updateById(mallGoods);
    }

    /**
     * 批量删除商城商品
     * 
     * @param ids 需要删除的商城商品ID
     * @return 结果
     */
    @Override
    public int deleteMallGoodsByIds(Long[] ids)
    {
        return mallGoodsMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除商城商品信息
     * 
     * @param id 商城商品ID
     * @return 结果
     */
    @Override
    public int deleteMallGoodsById(Long id)
    {
        return mallGoodsMapper.deleteById(id);
    }
}
